<!--用户管理-->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="li => selection = li">
      <template v-slot:form-right>
        <el-descriptions v-if="billData.id" title="" direction="vertical" :column="6" border  :labelStyle="{'min-width':'100px'}">
          <el-descriptions-item  :label="$tt('label_fms_account_cmp_customer')">{{
              billData.customerCode +
              billData.customerName
            }}
          </el-descriptions-item>
          <el-descriptions-item :label="$tt('label_fms_subject_bill_number')">{{
              billData.billNo
            }}
          </el-descriptions-item>
          <el-descriptions-item :label="$tt('label_fms_subject_bill_period')">{{
              billData.billMonth
            }}
          </el-descriptions-item>
          <el-descriptions-item :label="$tt('label_fms_subject_bill_amount')">{{
              billData.amount
            }}
          </el-descriptions-item>
          <el-descriptions-item :label="$tt('label_fms_bank_card_currency')">{{
              billData.currencyType
            }}
          </el-descriptions-item>
          <el-descriptions-item :label="$tt('label_fms_subject_bill_status')"> {{
              $tt('FmsBillStatusEnum__' +
                billData.status)
            }}
          </el-descriptions-item>
        </el-descriptions>
      </template>


      <template v-slot:bill-customer-info="{ row }">
        <div style=" white-space: nowrap; text-overflow: ellipsis; overflow: hidden; ">客户:
          {{ '[' + row.customerCode + ']' + row.customerName }}
        </div>
        <div style=" white-space: nowrap; text-overflow: ellipsis; overflow: hidden; ">账户: {{
            (row.accountType == 'CREDIT'
              ? ($enumShow(row.productType, 'PmsProductTypeEnum') + '-') : '') + $enumShow(row.currencyType,
              'CurrencyTypeEnum') + '-' + $enumShow(row.accountType, 'CustomerAccountTypeEnum')
          }}
        </div>
      </template>

      <template v-slot:bill-product-info="{ row }">
        <div style=" white-space: nowrap; text-overflow: ellipsis; overflow: hidden; ">单号：{{
            $enumShow(row.refOrderType,
              'OrderTypeEnum')
          }} {{
            (row.bizType !== '' && row.bizType !== undefined && row.bizType !== null) ? '[' +
              $enumShow(row.bizType, 'BizTypeEnum') + '] ' : ''
          }} - {{ row.productType=='EXPRESS' ? row.refSubOrderNo : row.refOrderNo }}
        </div>
        <div style=" white-space: nowrap; text-overflow: ellipsis; overflow: hidden; ">产品：{{
            '[' + row.productCode + '] '
            + row.productName
          }}
        </div>
      </template>

      <template v-slot:service-cost="{ row }">
        <div style=" white-space: nowrap; text-overflow: ellipsis; overflow: hidden; ">
          费用名称: {{ row.serviceName }}
        </div>
        <div style=" white-space: nowrap; text-overflow: ellipsis; overflow: hidden; ">
          费用金额: {{ row.serviceAmount }}
        </div>
      </template>

      <template v-slot:price-result-detail="{ row }">

        <template v-if="row.autoCreate == 'N'" style="text-align: left;">

          <div class="price-detail-class">
            <div class="price-detail-left-class">手动添加:</div>
            <div class="price-detail-right-class">{{ row.creator }} 创建于 {{ $dateFormat(row.gmtCreate) }}</div>
          </div>
        </template>

        <template v-else>

          <bill_detail_info :row="row"></bill_detail_info>

        </template>

        <div v-if="row.hasModify == 'Y'" class="price-detail-class">
          <div class="price-detail-left-class">最后修改:</div>
          <div class="price-detail-right-class">
            {{ row.lastModifyUser }} {{ $dateFormat(row.lastModifyTime) }}
          </div>
        </div>
      </template>

      <template v-slot:price-result-operate="{ row }">
        <div style="margin-left: 8px;">
          <el-button v-if="row.serviceCode == 'WAREHOUSE_RENT'"
                     @click="fmsOrderId = row.fmsOrderId; $refs['fmsTenantDetail'].showDetail()" type="text">{{
              $tt('label_fms_subject_detail')
            }}
          </el-button>

          <el-button v-if="row.status == 'INIT' || row.status == 'NEED_AUDIT'" v-auth="'fms_income_bill_detail_edit'"
                     @click="
              dialogTitle = $tt('label_edit');
            formValue = JSON.parse(JSON.stringify(row));
            formValue.isEdit = true;
            dialogFormVisible = true
              " type="text">
            {{ $tt('label_edit') }}
          </el-button>

          <el-popover v-if="row.hasModify == 'Y'" placement="right" width="500" trigger="hover"
                      @show="$refs['bill_detail_history_grid_' + row.id].loadData()">
            <ex-table-auto class="el-table-nowwarp" :ref="'bill_detail_history_grid_' + row.id"
                           :url="'/fms-api/customer/CustomerBillDetailRpc/history.json?billDetailId=' + row.id"
                           :autoFill="false"
                           :autoPage="false" :autoLoad="false" border>
              <el-table-column min-width="100" property="updateUser" label="修改人"></el-table-column>
              <el-table-column min-width="140" property="updateTime" label="时间">
                <template slot-scope="scope">
                  {{ $dateFormat(scope.row.updateTime) }}
                </template>
              </el-table-column>
              <el-table-column min-width="100" property="serviceAmount" label="修改后金额"></el-table-column>
            </ex-table-auto>
            <span slot="reference" style="color: #409EFF; cursor: pointer; margin-left: 8px;">修改记录</span>
          </el-popover>

        </div>

      </template>

    </ex_super_table_page>


    <el-dialog :title="dialogTitle" :visible.sync="importDiglogVisable" width="600px" :close-on-click-modal="false">
      <el-form :model="form" ref="form" label-position="top">
        <ex_header_spiler :title="$tt('label_batch_import')"></ex_header_spiler>
        <el-form-item>
          <el-button @click="downloadImportTemp" size="mini" type="primary" :disabled="loading" :loading="loading">{{
              $tt('label_download_import_template')
            }}<i class="el-icon-download el-icon--right"></i>
          </el-button>

          <el-upload v-auth="'oms_stock_head_query_import'" action="" :show-file-list="false" style="display: inline;"
                     :http-request="uploadFile">
            <el-button slot="trigger" size="mini" type="primary">{{ $tt('label_import_excel') }}</el-button>
          </el-upload>
        </el-form-item>
        <ex_header_spiler title="导入模板说明"></ex_header_spiler>
        <el-form-item style="font-size: 13px">
          <label>导入模板中，除了金额，其他全部为文本类型单元格</label><br>
          <label>目前仅支持导入【入库订单】、【出库订单】、【退货订单】的结算单，以下列举字段请使用实际的英文编码值，而非中文名称</label><br>
          <lebel>字段说明：</lebel><br>
          <label>业务类型：INBOUND("入库单"), OUTBOUND("出库单"),REFUND("退货订单")；</label><br>
          <label>产品类型：FIRST_TRANSPORT("头程"),LAST_TRANSPORT("尾程"),INSURANCE("保险"), WAREHOUSE("仓储")；</label><br>
          <label>费用类型：TRANSPORT("物流运输费"), INSURANCE("保险费"), WAREHOUSE("仓库操作费"), TENANT("仓租费用")；</label><br>
          <label>发生日期：格式为 yyyy/mm/dd ，如：2023/12/25</label><br>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" width="540px" :close-on-click-modal="false">
      <el-form ref="formEl" :model="formValue" :rules="rules" label-width="120px" class="common-form-panel-div"
               style="padding: 0px 10px; margin-top: 10px; ">

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_account_log_buss_type')">
              <!--  <el-input v-model="formValue.refOrderType"></el-input>-->
              <ex_super_input v-model="formValue.refOrderType" type="select" enum="OrderTypeEnum"
                              :disabled="formValue.isEdit" style="width: 100%;"></ex_super_input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_order_type')"
                          v-if="formValue.refOrderType === 'INBOUND' || formValue.refOrderType === 'OUTBOUND'">
              <ex_super_input v-model="formValue.bizType" type="select" enum="BizTypeEnum" :disabled="matchEdit"
                              style="width: 100%;"></ex_super_input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_account_log_buss_order_no')">
              <el-input v-model="formValue.refOrderNo" :disabled="formValue.isEdit"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_account_cmp_customer_name')">
              {{ formValue.customerCode ? ('[' + formValue.customerCode + '] ' + formValue.customerName) : '' }}
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_account_log_create_time')">
              <el-date-picker v-model="formValue.happenTime" type="datetime"
                              :placeholder="$tt('label_fms_subject_select_date')" value-format="timestamp"
                              style="width:100%;"
                              :disabled="formValue.isEdit">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item label="费用类别">
              <ex_super_input v-model="formValue.billCategory" type="select" enum="BillCategoryEnum"
                              style="width: 100%;">
              </ex_super_input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_expense_item_type')" prop="serviceCode">
              <ex_select_auto v-model="formValue.serviceCode" type="select"
                              url="/fms-api/agent/AgentServiceCostRpc/select.json" storeData
                              :option="{ label: 'serviceName', value: 'serviceCode' }"
                              :currentLabel="formValue.serviceName"
                              @changeItem="e => { formValue.serviceName = e.serviceName; }" style="width: 100%;"
                              :disabled="formValue.isEdit"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_expense_currency')">
              <el-input v-model="formValue.currencyType" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_expense_amount')">
              <el-input v-model="formValue.serviceAmount"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col>
            <el-form-item :label="$tt('label_fms_subject_remark')">
              <el-input v-model="formValue.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">{{ $tt('label_fms_account_config_cancel') }}</el-button>
        <el-button type="primary" @click="submitForm">{{ $tt('label_fms_account_config_confirm') }}</el-button>
      </div>
    </el-dialog>

    <fms-tenant-detail :fmsOrderId="fmsOrderId" ref="fmsTenantDetail"></fms-tenant-detail>

  </div>
</template>
<script>

import business_function from "@/common/business_function";

let moduleName = "label_fms_subject_manager"

import superTablePageFunction from '@/mixin/super-table-page-function';

import FmsTenantDetail from './dialog/fms-tenant-detail.vue'

import bill_detail_info from '@/component/fms/bill_detail_info.vue'


export default {

  title: moduleName,
  components: {FmsTenantDetail, bill_detail_info},

  mixins: [superTablePageFunction],
  data() {

    let _this = this

    return {
      form:{},
      loading:false,
      selection: [],
      matchEdit: false,
      formModel: 'insert/update',

      userTypeArr: [{id: 'ADMIN', name: '管理员'}, {id: 'OPERATOR', name: '操作员'}],
      roleSystemArr: [{id: 'WMS', name: 'WMS'}, {id: 'TMS', name: 'TMS 运输系统'}, {id: 'OMS', name: '业务后台系统'}],
      roleSystemMap: {},

      dialogFormVisible: false,
      importDiglogVisable: false,
      dialogTitle: '',
      formValue: {},
      rules: {
        companyName: [
          {required: true, message: '请输入企业名称', trigger: 'blur'},
          {min: 3, max: 32, message: '长度在 3 到 32 个字符', trigger: 'blur'}
        ],
        companyShortCode: [
          {required: true, message: '请输入企业编码', trigger: 'blur'},
          {min: 3, max: 16, message: '长度在 3 到 16 个字符', trigger: 'blur'}
        ]
      },

      billData: {
        'customerCode': '',
        'customerName': '',
        'status': ''
      },

      fmsOrderId: '-1'

    };
  },

  props: {
    'viewType': {
      type: String,
      default: 'detail'
    },
    'billId': {
      type: String,
      default: ''
    },
    'billNo': {
      type: String,
      default: ''
    }
  },

  watch: {
    'formValue.companyId'(val, old) {

    },

    'formValue.refOrderNo'(val, old) {


      let _this = this

      if (!val || val.length < 5) {
        return
      }

      _this.$ajax({
        url: '/fms-api/customer/CustomerOrderRpc/select.json?refOrderNo=' + val,
        success: (res) => {
          if (res && res.data && res.data.rows && res.data.rows.length > 0) {
            let order = res.data.rows[0]

            _this.formValue.refOrderType = order.refOrderType
            _this.formValue.currencyType = order.currencyType
            _this.formValue.customerCode = order.customerCode
            _this.formValue.customerName = order.customerName
            _this.formValue.bizType = order.bizType

            _this.matchEdit = true

          }
        }
      });

    }

  },

  created() {

    let _this = this

    if (_this.viewType == 'bill') {
      if (_this.billId == '') {
        alert('账单id为空')
      }
      _this.refreshBillData()
    }


    _this.roleSystemMap = {}
    _this.roleSystemArr.forEach(e => {
      _this.roleSystemMap[e.id] = e.name
    })

    _this.option = {
      search: {
        model: [
          {
            label: "label_fms_account_cmp_customer",
            key: "customerId",
            type: 'common_customer_choose',
            attrs: {multiple: false,},
            if: () => this.viewType == 'detail'
          },
          {
            label: "label_fms_account_apply_status",
            key: "status",
            type: 'select',
            enum: 'FmsBillDetailStatus',
            attrs: {clearable: true},
            if: () => this.viewType == 'detail'
          },
          {
            label: "label_fms_subject_product_type",
            key: "productType",
            type: 'select',
            enum: 'PmsProductTypeEnum',
            attrs: {clearable: true},
          },
          {
            label: "label_fms_account_log_buss_order_no", key: "refOrderNo", type: 'input',
          },
          {
            label: "是否系统自动创建", key: "isSystemAutoCreate", type: 'select',
            enum: 'YesOrNoEnum'
          },
          {
            label: "label_fms_account_log_happen_time", key: 'happenTime1', type: 'date-picker',
            attrs: { type: 'datetime' },
            on: { change: (e) => this.happenTime1 = e },
            pickerOptions: {
              disabledDate: (date) => this.happenTime2 ? (this.happenTime2 < date.getTime()) : false
            }
          },
          {
            label: "~", key: 'happenTime2', type: 'date-picker',
            attrs: { type: 'datetime' },
            on: { change: (e) => this.happenTime2 = e },
            'pickerOptions': {
              disabledDate: (date) => this.happenTime1 ? (this.happenTime1 > date.getTime()) : false
            }
          },

        ],
      },
      action: [
        {
          label: 'label_fms_subject_add',
          auth: 'fms_income_bill_detail_edit',
          attrs: {icon: "el-icon-plus"},
          click: () => {
            this.dialogTitle = this.$tt('label_fms_subject_add')
            this.dialogFormVisible = true
            this.formValue = {
              refOrderType: '',
              currencyType: ''
            }
            this.formValue.isEdit = false
          },
          if: () => this.viewType == 'detail' || (this.billData.status == 'BIZ_CONFIRM' || this.billData.status == 'FMS_REFUSE')
        },
        {
          label: 'label_fms_subject_gen_bill',
          auth: 'fms_income_bill_detail_gen',
          attrs: {icon: "el-icon-plus"},
          click: () => {
            this.createBill()
          },
          if: () => {
            return this.viewType == 'detail'
          }
        },
        {
          label: '批量结算', click: () => {
            this.importDiglogVisable = true
          },
        },
        {
          label: 'label_export', click: this.exportExcel
        }
      ],

      // actionExtra: [
      //   { label: 'label_batch_audit', attrs: { type: "primary" }, click: this.clickAuditList },
      //   { label: 'title_new_inbound_oder', attrs: { type: "primary" }, click: this.creatOrder },
      // ],

      table: {
        url: "/fms-api/customer/CustomerBillDetailRpc/select.json" + (this.viewType == 'bill' ? ('?billId=' + this.billId) : ''),
        attrs: {
          'cell-style': ({row, column, rowIndex, columnIndex}) => {
            if (column.property == 'status') {
              return {color: row.status == 'NORMAL' ? this.$globalCss.successColor : this.$globalCss.infoColor}
            }
          }
        },
        model: [
          {type: 'selection', clickToggle: true, keyGroup: 'label_table_operate', if: () => this.viewType == 'detail'},
          {
            key: 'refOrderType', label: 'label_fms_subject_order_type', align: 'left', 'min-width': 200,
            slot: 'bill-product-info'
          },
          {
            key: 'companyName', label: '客户名称', align: 'left', 'min-width': 120,
            slot: 'bill-customer-info'
          },
          {
            key: 'serviceName', label: 'label_fms_service_code_expense_item_name', align: 'left', 'min-width': 140,
            slot: 'service-cost'
          },
          {
            key: 'happenTime', label: 'label_fms_account_log_create_time', 'min-width': 100, attrs: {
              formatter: (r, c, v, i) => {
                return this.$dateFormat(v)
              }
            }
          },
          {
            key: 'status', label: 'label_fms_account_apply_status', align: 'center', 'min-width': 100,
            attrs: {
              formatter: (r, c, v, i) => {
                return this.$enumShow(v, 'FmsBillDetailStatus')
              }
            }
          },
          {
            key: 'chargeType',
            label: 'label_fms_subject_formula_mode',
            slot: 'price-result-detail',
            align: 'center',
            'min-width': 280
          },
          {
            key: 'remark', label: 'label_fms_subject_remark', align: 'left', 'min-width': 120,'show-overflow-tooltip': true
          },
          {
            key: 'chargeType',
            label: 'label_table_operate_area',
            'width': 200,
            slot: 'price-result-operate',
            align: 'left'
          }

        ]
      }
    }

  },


  destroyed() {

  },

  methods: {


    getChargeUnitName(chargeType) {
      if (chargeType == 'CAL_WEIGHT' || chargeType == 'WEIGHT') {
        return 'Kg'
      } else if (chargeType == 'VOLUME') {
        return 'Cbm'
      }
      return ''
    },

    getChargeUnitBy(chargeType) {

      if (chargeType == 'CAL_WEIGHT' || chargeType == 'WEIGHT') {
        return '重量'
      } else if (chargeType == 'VOLUME') {
        return '体积'
      } else if (chargeType == 'PACKAGE') {
        return '包裹数'
      } else if (chargeType == 'PERCENT') {
        return '百分比'
      } else if (chargeType == 'PCS') {
        return 'SKU件数'
      } else if (chargeType == 'BOX') {
        return '箱数'
      } else if (chargeType == 'ORDER') {
        return '订单数'
      }

    },

    renderCalInfos(row) {

      if (row.autoCreate == 'N') {
        return '手动添加'
      }

      let r = row.priceResult

      if (!r || !r.chargeType) {
        return ''
      }


      /*
      {
        "amount": 541.561032,
        "chargeType": "VOLUME",
        "firstPrice": 0,
        "firstNum": 0,
        "price": 12,
        "nums": 45.130086,
        "additionalAmount": 0
      }*/

      if (r.chargeType == 'WEIGHT' || r.chargeType == 'CAL_WEIGHT') {

        let head = r.chargeType == 'WEIGHT' ? '重量' : '计费重量'

        if (r.priceType == 'SINGLE') {
          return `单价 ${r.price} * ${head} ${r.nums}`
        } else if (r.priceType == 'ADD') {
          if (r.nums < r.firstNum) {
            return `首重价 ${r.firstPrice}, (重量 ${r.nums})`
          } else {
            return `（ ${r.nums}-${r.firstNum} ）x 续重价 ${r.price} + 首重价 ${r.firstPrice}`
          }
        } else if (r.priceType == 'TOTAL') {
          return `总价 ${r.price}, ${head}:${r.nums}`
        } else {
          return `单价 ${r.price} * ${head} ${r.nums}`
        }
      } else if (r.chargeType == 'VOLUME') {
        let head = '体积'
        if (r.priceType == 'SINGLE') {
          return `单价 ${r.price} * ${head} ${r.nums}`
        } else if (r.priceType == 'TOTAL') {
          return `总价 ${price}, ${head}:${nums}`
        } else {
          return `单价 ${r.price} * ${head} ${r.nums}`
        }
      } else if (r.chargeType == 'PERCENT') {

        if (row.serviceCode == 'INSURANCE') {
          return `投保金额 ${r.nums} ${r.currency} * 费率 ${r.price}% `
        }

        return `总额 ${r.nums} ${r.currency} * ${r.price}% `

      } else if (r.chargeType == 'PACKAGE') {
        return `单价 ${r.price} * ${r.nums}包`
      } else if (r.chargeType == 'PCS') {
        return `单价 ${r.price} * ${r.nums}件`
      } else if (r.chargeType == 'BOX') {
        return `单价 ${r.price} * ${r.nums}箱`
      } else if (r.chargeType == 'ORDER') {
        return `单价 ${r.price} * ${r.nums}件`
      }


      //  chargeType;
      // calFirstPrice;
      // calPrice;
      // calNums;

      return JSON.stringify(r)

      return ''

    },


    refreshBillData() {
      let _this = this

      _this.$ajax({
        url: '/fms-api/customer/CustomerBillRpc/detail.json?id=' + _this.billId,
        success: (res) => {
          if (res && res.data) {
            _this.billData = res.data
          }
        }
      });
    },

    createBill() {

      if (!this.selection || this.selection.length == 0) {
        this.$message({
          type: 'error',
          message: '没有选中结算单'
        });
        return
      }

      let customerSize = 0
      let doneSize = 0
      let str = ''
      this.selection.forEach(e => {
        if (str.indexOf(e.customerId) == -1) {
          str = str + e.customerId + ','
          customerSize++
        }

        if (e.status != 'INIT') {
          doneSize++
        }

      })

      if (doneSize == this.selection.length) {
        this.$message({
          type: 'error',
          message: '没有可以生成账单的记录，只有`未入账`的结算单才能生成账单'
        });
        return
      }

      let msg = `本次操作共选中${customerSize}个客户，${this.selection.length}条结算单`

      if (doneSize > 0) {
        msg += `<br/>其中${doneSize}条已生成过账单， 确定需要对剩下${this.selection.length - doneSize}的条生成账单吗 ?`
      } else {
        msg += `<br/>确定要生成账单吗 ？`
      }

      this.$confirm(msg, this.$tt('label_tip'), {
        type: 'warning',
        dangerouslyUseHTMLString: true,
        confirmButtonText: this.$tt('label_fms_subject_gen_bill'),
        cancelButtonText: this.$tt('label_fms_account_config_cancel')
      })
        .then(() => {

          let ids = this.selection.filter(e => e.status == 'INIT').map(e => e.id)

          this.$ajax({
            url: '/fms-api/customer/CustomerBillRpc/createBill.json',
            data: {
              'ids': JSON.stringify(ids)
            },
            success: (res) => {
              this.$message({
                showClose: true,
                message: '提交成功',
                type: 'success'
              })
              this.$refs['SuperTablePage'].reload()
            }
          });

        })
        .catch(action => {

        });


    },

    submitForm() {


      this.$refs['formEl'].validate((valid) => {
        if (valid) {

          if (this.viewType == 'bill') {
            this.formValue.billId = this.billId
          }

          this.$ajax({
            url: '/fms-api/customer/CustomerBillDetailRpc/saveUpdate.json',
            type: 'json',
            data: this.formValue,
            success: (res) => {
              this.$message({
                showClose: true,
                message: '提交成功',
                type: 'success'
              })
              this.$refs['SuperTablePage'].reload()
              this.dialogFormVisible = false

              if (this.viewType == 'bill') {
                this.refreshBillData()
              }

            }
          });

        } else {
          return false;
        }

      });

    },

    downloadImportTemp() {
      if (this.$clickFast()) return
      this.$downloadFile({
        loading: true,
        url: '/fms-api/customer/CustomerBillDetailRpc/downloadImportTemp.json',
      })
    },
    uploadFile(cfg) {
      this.$uploadFile({
        loading: true,
        url: '/fms-api/customer/CustomerBillDetailRpc/importExcel.json',
        file: cfg.file,
        success: (res) => {
          this.$emitPage("oms>import_manage", 'reload')
          this.importDiglogVisable = false
          this.$confirm(this.$tt("tip_importing_confirm_goto_recode_list"), this.$tt('label_tip'), {
            type: 'success'
          }).then(() => {
            this.$router.push({
              path: '/page/oms/report/import_manage',
            });
          }).catch(() => {
          });
        }
      })
    },
    exportExcel() {
      business_function.confirmOperateBaseSelectOrForm.call(this, {
        data: this.$refs.SuperTablePage.getSearchFormData(),
        model: this.option.search.model,
        selection: this.selection,
        callback: (selection, data) => {
          let params = {}
          if (!_.isEmpty(selection)) {
            params = {
              idList: selection.map(it => it.id)
            }
          } else {
            params = data
          }
          this.$functionCommon({
            url: '/fms-api/customer/CustomerBillDetailRpc/export.json',
            data: params
          })
        }
      })
    },


  }
};

</script>
<style>
.small-btn span {
  font-size: 14px;
}

.small-btn .el-button--small span {
  font-size: 14px;
}
</style>
